Imports iConverter.Contracts

Namespace Extensions
    ''' <summary>
    ''' 后期处理插件
    ''' </summary>
    ''' <remarks></remarks>
    Public Class PostProcessing
        Inherits Plugin

        ''' <summary>
        ''' 创建新的插件实例
        ''' </summary>
        ''' <param name="provider">提供插件的提供器</param>
        ''' <param name="plugin">插件对象</param>
        ''' <remarks></remarks>
        Friend Sub New(ByVal provider As PluginProvider, ByVal plugin As Object)
            MyBase.New(provider, plugin)


            Me._plugin = DirectCast(plugin, IPostProcessing)
            Me._plugin = DirectCast(plugin, IPostProcessingMetadata)
        End Sub



        ''' <summary>
        ''' 插件对象
        ''' </summary>
        ''' <remarks></remarks>
        Dim _plugin As IPostProcessing

        ''' <summary>
        ''' 插件对象
        ''' </summary>
        ''' <remarks></remarks>
        Private ReadOnly Property Plugin() As IPostProcessing
            Get
                Return _plugin
            End Get
        End Property

        ''' <summary>
        ''' 插件元数据
        ''' </summary>
        ''' <remarks></remarks>
        Dim _metadata As IPostProcessingMetadata

        ''' <summary>
        ''' 插件元数据
        ''' </summary>
        ''' <remarks></remarks>
        Private ReadOnly Property Metadata() As IPostProcessingMetadata
            Get
                Return _metadata
            End Get
        End Property


#Region "后期处理方法"

        Dim _Processings As List(Of Processer)

        Public ReadOnly Property Processings As List(Of Processer)
            Get
                If Me._Processings Is Nothing Then
                    Me._Processings = ExtensionsFactory.CreateProcessings(Me, Me.Plugin.GetProcessings)
                End If
                Return _Processings
            End Get
        End Property



#End Region



#Region "IDisposable Support"

        Protected Overrides Sub Dispose(disposing As Boolean)
            If Not Me.disposedValue Then
                If disposing Then
                    For Each p In Me._Processings
                        p.Dispose()
                    Next

                    Me._Processings.Clear()
                End If

                Me._Processings = Nothing
                Me._metadata = Nothing
                Me._plugin = Nothing
            End If
            Me.disposedValue = True
        End Sub


#End Region

    End Class

End Namespace
